Repository navigation
chore(examples): add tasks-axi-rust read-path prototype generated from a MetaObjects model - #606
Merged
Merged
Conversation
…ects model Adds examples/tasks-axi-rust: show, list and ready of tasks-axi 0.2.6 as a small Rust binary. The Rust for rows, enums, error codes, the argument parser, help text and dispatcher is emitted by an owned generator (model reader, IR, text emitter) from a model whose command surface lives in one attr.properties bag. The generated crate is committed as the golden spec for a Rust-native generator. Hand-written: the backlog grammar and derived state, a std-only TOON encoder checked against the official fixtures, and a std-only JS regex engine differentially tested against node. Gates: drift (meta verify --codegen), compile + rustfmt, clippy, cargo test with recorded golden outputs, and a differential harness that runs the real tasks-axi and the Rust binary over seeded synthetic backlogs. Writes are refused with a clear error. No change to MetaObjects core, vocabulary or server/rust.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/tasks-axi-rust/reimplements the read path of the tasks-axi task tracker (show,list,ready) as a small Rust binary,tasks-axi-rs. The Rust source for its rows, enums, error codes, argument parser, help text and dispatcher is generated from a MetaObjects model by an owned TypeScript generator (model reader, then IR, then rustfmt'd text emitter). The real tasks-axi 0.2.6 is the byte-exact oracle. Writes are not implemented; they are refused with a clear error. No MetaObjects core, vocabulary, version orserver/rustchange; the one change outside the example is a test-helper repair described below.Before and after (release build, 200-task synthetic backlog, 30 interleaved warm runs after a warm-up)
The machine was heavily loaded (load average about 26), so read the ratios and the CPU column, not the absolute milliseconds.
Start-up dominates: on a 5-task backlog node still takes about 40 ms per call (list 40.4, ready 41.3, show 41.3) against 0.7 to 0.9 ms for Rust, with peak memory about 60 MiB against 9 MiB. The release binary is about 0.5 MB and the workspace has no crates.io dependencies. Reproduce with
python3 bench/bench.py(it refuses to time a scenario whose outputs differ).Differential result
bun harness/differential.tsruns the real tasks-axi andtasks-axi-rsover seeded synthetic backlogs (awkward Unicode, lone surrogates, CRLF, quoting edge cases, duplicate ids, blocked-by chains, expiring holds, control characters) and a matrix of commands, flags, config sources and error cases, requiring identical stdout bytes, exit code and an empty stderr. Result: 1,671 comparisons (40 seeds) with 0 differences plus 25 refusals asserted, and a wider earlier run of about 6,000 comparisons over 190 seeds with 0 differences. 148 recorded outputs from the real tool are also replayed bycargo test, so the Rust side is checkable without node. Every backlog is synthetic. The harness caught one real defect during development: the shipped@toon-format/toonquotes strings differently from the spec in three places, which is whycrates/toonhas aDialect::ToonJs2mode.Deliberate differences, all documented in the example README: top-level
--helpis this tool's own text, the dashboard (no command) is refused, every write command is refused (exit 1, codeUNSUPPORTED, even with--help), a backlog containing apublic-followuptask is refused, and only the markdown backend is supported.Generated versus hand-written (from the example README)
crates/tasks-axi-gen/: enums, model structs,TaskRowand its columns, error codes and exit codes, help/usage/hint text, flag parser and validation, dispatcher andHandlerstraitmetaobjects/meta.tasks.yamlandmeta.cli.yaml; committed as the golden spec for a future Rust-native generator;meta verify --codegenfails on a stale or hand-edited copycli.rscrates/tasks-axi-rs/: backlog grammar, link and dependency derivation, blocked/held/ready semantics, config and file discovery, hint suffixes, truncation, TOON viewsHandlersseamcrates/toon/(TOON v4.1 encoder, 179 of 179 official fixtures) andcrates/jsre/(JS regex engine, differentially tested against node)The generator is split model reader / IR / text emitter on purpose, so the IR and the committed goldens are the contract a Rust-native generator would reproduce. The command surface has no registered vocabulary, so it lives in one
attr.propertiesbag; the README records what that bag had to carry as evidence for a possible futurebinding.cli.Things a reviewer should know
scripts/ci-local.sh --affectedfailed on one TypeScript test (owned-copies-current: the owned-tier discovery treatedexamples/tasks-axi-rust/codegen/generatorsas an owned-copy tier, but it holds one bespoke generator and no ejected reference copy). The pipeline agent repairedownedTiers()inserver/typescript/packages/cli/test/support/owned-tiers.ts(an example now counts only if its generators directory holds a reference-named copy) and re-ran that test file and the fullserver/typescriptsuite green, and the sync script's--checkstill reports all 128 owned copies current. The full local CI run was not repeated end to end after the repair; the hosted checks on this PR are the confirmation.scripts/ci-lane-map.txthas no rule forexamples/tasks-axi-rust/*. No existing lane runs this example's tests or compile gate (therustlane runs onlyserver/rust), so the path is left unmapped and selects every lane. The example's own gates run withexamples/tasks-axi-rust/scripts/gates.sh.What Changed
examples/tasks-axi-rust/, a self-contained prototype reimplementing the tasks-axi read path (show,list,ready) as a Rust binary whose rows, enums, error codes, argument parser, help text and dispatcher are generated by an owned TypeScript generator (codegen/generators/rust-cli.ts, layered as read-model → IR → rustfmt'd emit) frommetaobjects/meta.tasks.yamlandmeta.cli.yaml; the generated Rust is committed as golden outputs undercrates/tasks-axi-gen/, with the hand-written crate behind aHandlerstrait seam, plus golden/differential harness files (harness/,scripts/gates.sh) pinning byte-identical output and exit codes against the real tasks-axi 0.2.6.crates/toon(a std-only TOON v4.1 encoder passing all 179 official encoder fixtures, with aDialect::ToonJs2mode for the JS library's quoting differences) andcrates/jsre(a std-only JavaScript regex engine, differentially tested against node's regexes).ownedTiers()inserver/typescript/packages/cli/test/support/owned-tiers.tsand the sync script's comments) so an example whosecodegen/generators/holds only bespoke generators — none ejected from a reference generator — is not treated as an owned tier.Validation
Risk Assessment
✅ Low: The fix round only moved the
basecolumn-set into emitted constants (generated cli.rs/rows.rs hashes match the committed .hashes.json) and added control-character strings to the synthetic vocabulary with goldens re-recorded; no new defect found.Testing
Drove the Rust read path end-to-end against the real oracle and exercised the review-round fixes. (1) The built tasks-axi-rs binary answered list/ready/show on a synthetic backlog with byte-identical stdout, stderr and exit codes to the real tasks-axi 0.2.6, plus correct refusal (exit 1) and unknown-command (exit 2) behavior. (2) The codegen contract held: meta verify --codegen clean on the committed example, a clean regen reproduces crates/tasks-axi-gen byte-for-byte, and both adversarial model typos (row:/base: on the columns flag) now fail meta gen with precise errors — the review fix is live. (3) The example's own gates passed: cargo test --workspace green including the re-recorded goldens whose titles/bodies carry ANSI-escape control characters, and the differential harness compared 1671 outputs against the real tool with 0 failures. The configured test command reproduced red on exactly one test — the owned-copies gate over-capturing the new example's bespoke generator directory as an owned-eject tier; I repaired the discovery in cli/test/support/owned-tiers.ts (uncommitted, in the working tree) and re-verified the failing test file, the full server/typescript suite, and the sync script's check all green. Every other lane (java, python, csharp, rust, ts build/typecheck/unit/mutation) was green in the same full run; the repair touches only the ts lane's test support. All scratch (backlogs, typo copy, cargo target) removed; no processes left running.
Evidence: Scenario 1 — read path vs real oracle (transcript)
tasks-axi-rs list --file backlog.md → count: 4, TOON rows; oracle comparison loop: MATCH (exit 0) for list/ready/show beta-02/show epsilon-05/show gamma-03; add → UNSUPPORTED exit 1; frobnicate → VALIDATION_ERROR exit 2Evidence: Scenario 2 — codegen freshness + adversarial typos
meta verify --codegen exit 0; row typo → 'row TaskRwo is not TaskRow' exit 1; base typo → 'unknown column set TaskListRwo' exit 1; clean regen byte-identical to committed crateEvidence: Scenario 3 — example gates (goldens + differential)
cargo test --workspace green incl. control-char goldens; differential: 1671 compared, 25 refusals checked, 0 failed (31.7s)Evidence: CI failure reproduced and repaired
conformance: typescript — 1 fail of 2100: 'examples/tasks-axi-rust/codegen/generators holds at least one owned copy' (size 0). Root cause + repair + verification documentedEvidence: Full configured CI run log
scripts/ci-local.sh --affected --strict-toolchains: java 7m12s ✓, python 5m53s ✓, csharp 3m47s ✓, rust 5s ✓, ts build/typecheck/unit/mutation ✓, conformance: typescript ✖ (1 test) — failure at log line 28771Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
examples/tasks-axi-rust/codegen/rust/read-model.ts:127- Thecolumnsflag'srow:/base:cross-references are read into the IR but never validated and never consumed:flagOfjustString()s them, and the emitter hardcodes the available-column list (codegen/rust/emit/cli.ts:221—parse_columns(..., &LIST_EXTRA_COLUMNS), ignoringf.flag.row/f.flag.base; no other file reads them). Yetmetaobjects/meta.cli.yaml:9-11("Conventions the generator enforces: everycolumns/extraname must be a TaskRow column") andREADME.md:102-105("acolumnsflag names a row type and a base row type ... Four checks of this kind live in the generator") both claim a typo there failsmeta gen. It does not:fields: { name: fields, type: columns, row: TaskRwo, base: TaskListRwo }regenerates cleanly. The other three claimed checks are real (enum→model enum at read-model.ts:175-177, output→row set at :167, extra→column at :169); only this one is absent, so the model data is inert and the two committed claims are factually wrong.examples/tasks-axi-rust/harness/synthetic-backlog.ts:31- The hold-expiry boundary can never be exercised: hold-until values are drawn only from fixed PAST (2000-2010) and FUTURE (2500-3000) pools, so no synthetic backlog ever holds a task whosehold-untilequals the run date.is_hold_active(crates/tasks-axi-rs/src/derive.rs:59) uses a strict>("strict upper bound", per the porter); if the real tool compares inclusively (>=),list --state held,readyandready --include-heldsilently disagree with the oracle exactly on that day — a divergence class both the differential harness and the recorded goldens are structurally unable to catch with this vocabulary. Adding the current date to the hold-until pool (and re-recording the goldens, since seeds 1-3 feed them) closes it.examples/tasks-axi-rust/crates/tasks-axi-rs/src/config.rs:129- The three TOML-parsing regexes compiled here (^\[([^\]]+)\]$,^([A-Za-z0-9_]+)\s*=\s*(.*)$,^-?\d+$, config.rs:129-131) are the only jsre uses outside the differentially-tested pattern list —crates/jsre/tests/differential.rs:380-714covers only the markdown-grammar and URL patterns. The constructs involved (anchored classes,\s*,.*) are exercised indirectly by other patterns in the corpus, so the residual risk is small, but a jsre defect specific to one of these three shapes would corrupt config-path/backend parsing with no oracle catching it. Adding them topatterns()is a few lines in the differential test.🔧 Fix applied.
5 issues (1 warning, 4 infos) still open:
examples/tasks-axi-rust/codegen/rust/read-model.ts:127- Thecolumnsflag'srow:/base:cross-references are read into the IR but never validated and never consumed:flagOfjustString()s them, and the emitter hardcodes the available-column list (codegen/rust/emit/cli.ts:221—parse_columns(..., &LIST_EXTRA_COLUMNS), ignoringf.flag.row/f.flag.base; no other file reads them). Yetmetaobjects/meta.cli.yaml:9-11("Conventions the generator enforces: everycolumns/extraname must be a TaskRow column") andREADME.md:102-105("acolumnsflag names a row type and a base row type ... Four checks of this kind live in the generator") both claim a typo there failsmeta gen. It does not:fields: { name: fields, type: columns, row: TaskRwo, base: TaskListRwo }regenerates cleanly. The other three claimed checks are real (enum→model enum at read-model.ts:175-177, output→row set at :167, extra→column at :169); only this one is absent, so the model data is inert and the two committed claims are factually wrong.examples/tasks-axi-rust/harness/synthetic-backlog.ts:31- The hold-expiry boundary can never be exercised: hold-until values are drawn only from fixed PAST (2000-2010) and FUTURE (2500-3000) pools, so no synthetic backlog ever holds a task whosehold-untilequals the run date.is_hold_active(crates/tasks-axi-rs/src/derive.rs:59) uses a strict>("strict upper bound", per the porter); if the real tool compares inclusively (>=),list --state held,readyandready --include-heldsilently disagree with the oracle exactly on that day — a divergence class both the differential harness and the recorded goldens are structurally unable to catch with this vocabulary. Adding the current date to the hold-until pool (and re-recording the goldens, since seeds 1-3 feed them) closes it.examples/tasks-axi-rust/codegen/rust/read-model.ts:177- The fix round makesrow:andbase:validated (a typo now failsmeta gen, so the two committed claims in meta.cli.yaml:9 and README.md:102 are now true for typos). Butbaseis still not consumed by the emitter:emit/cli.ts:221always passes&LIST_EXTRA_COLUMNS, whichemit/rows.ts:122derives from TaskListRow only. A model edit tobase: TaskDetailRowpasses validation and silently emits the list set. Not reachable with the committed model, so the narrow fix is acceptable; emitting the constant fromf.flag.basewould close it.examples/tasks-axi-rust/harness/synthetic-backlog.ts:118- The differential and golden vocabulary has no ASCII control characters other than tab (STRANGE_BODY / WORDS carry NBSP, BOM, NEL and em-space, but never U+0001-U+001F).crates/toon/src/lib.rsquote()emits\u00XXfor those, which matches the TOON v4.1.1 spec fixtures. Nothing compares that against the shipped@toon-format/toon2.3.x the tool must match byte for byte. A title containing an ANSI escape (U+001B) is a realistic backlog line, and it is the only place a mismatch would show. Adding one or two control-character strings (e.g."\u{001b}[0m","\u{0001}") to WORDS or STRANGE_BODY, then re-recording the goldens, would settle it against the real tool.examples/tasks-axi-rust/crates/jsre/tests/differential.rs:718- Whennodeis not on PATH the differential test printsSKIPPEDand returns, so it passes.scripts/gates.sh --no-nodestep 4 (cargo test --workspace) therefore reports the regex engine as differentially verified when nothing ran. This is a deliberate skip, and the message is visible with--nocapture. It is worth knowing that a green--no-nodegate does not cover jsre against the oracle.🔧 Fix applied.
2 infos still open:
examples/tasks-axi-rust/harness/synthetic-backlog.ts:31- The hold-expiry boundary can never be exercised: hold-until values are drawn only from fixed PAST (2000-2010) and FUTURE (2500-3000) pools, so no synthetic backlog ever holds a task whosehold-untilequals the run date.is_hold_active(crates/tasks-axi-rs/src/derive.rs:59) uses a strict>("strict upper bound", per the porter); if the real tool compares inclusively (>=),list --state held,readyandready --include-heldsilently disagree with the oracle exactly on that day — a divergence class both the differential harness and the recorded goldens are structurally unable to catch with this vocabulary. Adding the current date to the hold-until pool (and re-recording the goldens, since seeds 1-3 feed them) closes it.examples/tasks-axi-rust/crates/jsre/tests/differential.rs:718- Whennodeis not on PATH the differential test printsSKIPPEDand returns, so it passes.scripts/gates.sh --no-nodestep 4 (cargo test --workspace) therefore reports the regex engine as differentially verified when nothing ran. This is a deliberate skip, and the message is visible with--nocapture. It is worth knowing that a green--no-nodegate does not cover jsre against the oracle.server/typescript/packages/cli/test/support/owned-tiers.ts:30- The configured test command failed on the only red gate, conformance: typescript: 'owned reference-template copies are whatmeta ejectwrites > examples/tasks-axi-rust/codegen/generators holds at least one owned copy' (owned-copies-current.test.ts:46, expected.generators.size 0). Root cause: ownedTiers() discovery treats every examples/*/codegen/generators directory as an owned-copy tier, and the gate then demands at least one reference-named eject in it. The new example holds only rust-cli.ts — a bespoke from-scratch generator (the example's stated design), not an eject of a reference template. REPAIRED in this run (working tree, uncommitted): ownedTiers() now includes an example only when its generators/ dir holds a file named for a reference generator, matching the sync script's own rule that it never introduces an owned generator into an example ('which copies an example owns is that example's decision'). Verified: the failing test file 136/136 green, and the full server/typescript bun test run (221 files, the same runner and file set as the failing CI step) 2098 tests 0 fail; scripts/sync-owned-template-copies.ts --check still reports all 128 owned copies current. Existing tiers (test-generators, advanced-modeling, showcase) unaffected.scripts/ci-local.sh --affected --strict-toolchainsscripts/ci-local.sh --affected --strict-toolchains (full reproduction of the configured test command; all lanes; 1 test failure in conformance: typescript, all other lanes green — log at evidence/ci-full-rerun.log)cargo build --workspace (examples/tasks-axi-rust, scratch CARGO_TARGET_DIR)tasks-axi-rs list/ready/show/add/frobnicate against a hand-written synthetic backlog, byte-compared (stdout+stderr+exit code) against the real tasks-axi 0.2.6 on PATHbun run packages/cli/bin/meta.ts verify --codegen --cwd examples/tasks-axi-rust (drift gate)meta gen with an adversarial 'row: TaskRwo' typo and a 'base: TaskListRwo' typo in a scratch copy of the example (both must fail; both did)meta gen on the clean scratch copy, byte-compared per file against the committed crates/tasks-axi-gen/src/*.rscargo test --workspace (examples/tasks-axi-rust: golden replay incl. new control-char fixtures, TOON conformance, JS-regex differential)bun harness/differential.ts --seeds 40 (real tasks-axi 0.2.6 vs tasks-axi-rs)bun test packages/cli/test/owned-copies-current.test.ts (failing test after repair: 136 pass, 0 fail)bun scripts/sync-owned-template-copies.ts --check (128 owned copies current)bun test (server/typescript, full: 2098 tests, 0 fail, after repair)🔧 **Document** - 1 issue found → no changes applied ✅
docs/recipes/write-your-own-generator.md- The new example is the repo's flagship worked demonstration of write-your-own-generator for a language with no port (and evidence for a future binding.cli), but no user-facing doc points at it: docs/recipes/write-your-own-generator.md names none of the example dirs, docs/README.md's 'When to read which' table and the root README's examples pointers list only advanced-modeling. That listing already abridges examples/ (brownfield and showcase are equally unlisted), so nothing is factually stale — this is a discoverability judgment call, not a defect, and I did not add pointers unilaterally.🔧 No changes applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.